package com.mobjam.workingtitleforagame;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class StoreGalleryAdapter extends BaseAdapter {
	
	private Context context;
	private Item data[]=null;
	
	public StoreGalleryAdapter(Context context, Item[] data) {
		super();
		this.context = context;
		this.data = data;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v;
		if (convertView == null)
			v = LayoutInflater.from(context).inflate(R.layout.store_gallery_item, parent, false);
		else
			v = convertView;
		
		Item item = data[position];
		
		TextView storeItemName = (TextView) v.findViewById(R.id.textView1);
		storeItemName.setText(item.name);
		ImageView imageView = (ImageView) v.findViewById(R.id.itemImageView1);
		imageView.setImageDrawable(item.icon);
		imageView.setBackgroundColor(Color.WHITE);
		return v;
	}

}
